package com.glela.order.service.impl.order.amqp;

import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import com.glela.cache.redis.RedisKeys;
import com.glela.cache.redis.RedisUtil;

/**
 * **********************************************
 * 
 * @Title: 死信队列监听(暂时不做处理 只记录在redis中)
 * @throws @author
 *             gaoweiqi
 * @version 0.0.0.1
 * @since 2018年5月4日 下午1:05:35
 * 
 *        **********************************************
 */
public class XDLMessage implements MessageListener {

	private static Logger logger = LoggerFactory.getLogger(WaitingCommision.class);
	public static final String APPID = "小铺来了";
	RedisUtil redisUtil;

	/**
	 * 用来记录队列消息 记录条件： 消息被拒绝 消息TTL过期 队列达到最大长度
	 */
	public void onMessage(Message message) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("body", new String(message.getBody()));
		map.putAll(message.getMessageProperties().getHeaders());
		map.put("MessageId", message.getMessageProperties().getMessageId());
		redisUtil.sadd(RedisKeys.ORDER_AMQP_ADD_COMMISION_ERROR, map.toString());
		String orderSn = new String(message.getBody());
		logger.info("消费队列：Message:{}", orderSn);// 暂时不作处理
	}
}
